<?php

declare(strict_types=1);

namespace app\admin\service\settings;

use app\common\service\ConfigService;
use Dengje\Pxy\BaseService;

class AppService extends BaseService
{

    public function app($data)
    {
        $data = $this->preExcludeFields($data);
        $list = [];
        if ($data['type'] == 1) {
            $app_wx = implode(',', $data['app_wx']);
            $app_xcx = implode(',', $data['app_xcx']);
            ConfigService::set('applet', 'app_wx', $app_wx);
            ConfigService::set('applet', 'app_xcx', $app_xcx);
        } else {
            $app_wx = ConfigService::get('applet', 'app_wx');
            $app_xcx = ConfigService::get('applet', 'app_xcx');
            $list['app_wx'] =  $app_wx ? explode(',', $app_wx) : [];
            $list['app_xcx'] =  $app_xcx  ? explode(',', $app_xcx) : [];
        }
        return $list;
    }
}
